<?php
header("Content-Type:text/html;charset=utf-8"); 

include ("../conn.php");

//登录校验
if(isset($_POST['submit'])){
	$user=mysql_real_escape_string($_POST['username']);
	$pwd=mysql_real_escape_string($_POST['pwd']);
	$sql="select USERNAME,PWD FROM ".$databasepre."admin where USERNAME='".$user."' and PWD='".$pwd."'";
	//echo $sql;
	//exit;
	$query=mysql_query($sql);
	if($row=mysql_fetch_array($query)) {
		@session_start();
		$_SESSION['username']=$row['USERNAME'];
		$_SESSION['pwd']=$row['PWD'];
		Header("Location:index.php");
		//echo "如果没有自动跳转，请点击这里 <a href='index.php'>管理平台</a>";
		//echo "<script language='javascript'>alert('校验成功，马上进入管理平台!');window.location.href='index.php';</script>";
	} else {
		echo "<script>alert('对不起！用户名或密码不对，请重新输入！');history.go(-1);</script>";
	}



}

?>


<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>管理员登陆</title>
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-color: #1D3647;
}
-->
</style>
<SCRIPT language=javascript>
function Checklogin()
{
	if (form1.username.value=="")
	{
		alert("请填写登录名");
		form1.username.focus();
		return false;
	}
	if (form1.pwd.value=="")
	{
		alert("密码不能为空");
		form1.pwd.focus();
		return false;
	}
}
</SCRIPT>

<link href="images/skin.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="100%" height="166" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td height="42" valign="top"><table width="100%" height="42" border="0" cellpadding="0" cellspacing="0" class="login_top_bg">
      <tr>
        <td width="1%" height="21">&nbsp;</td>
        <td height="42">&nbsp;</td>
        <td width="17%">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td valign="top"><table width="100%" height="532" border="0" cellpadding="0" cellspacing="0" class="login_bg">
      <tr>
        <td width="49%" align="right"><table width="91%" height="532" border="0" cellpadding="0" cellspacing="0" class="login_bg2">
            <tr>
              <td height="138" valign="top"><table width="89%" height="427" border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <td height="149">&nbsp;</td>
                </tr>
                <tr>
                  <td height="80" align="right" valign="top"><img src="images/logo2.gif" width="442" height="142"></td>
                </tr>
                <tr >
                  <td height="198" align="right" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td width="35%">&nbsp;</td>
                      <td height="25" colspan="2" class="left_txt"><p>&nbsp;</p></td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td height="25" colspan="2" class="left_txt"><p>&nbsp;</p></td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td height="25" colspan="2" class="left_txt"><p>&nbsp;</p></td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td width="30%" height="40">&nbsp; </td>
                      <td width="35%">&nbsp;</td>
                    </tr>
                  </table></td>
                </tr>
              </table></td>
            </tr>

        </table></td>
        <td width="1%" >&nbsp;</td>
        <td width="50%" valign="bottom"><table width="100%" height="59" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
              <td width="4%">&nbsp;</td>
              <td width="96%" height="38"><span class="login_txt_bt">登陆信息网后台管理</span></td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td height="21"><table cellSpacing="0" cellPadding="0" width="100%" border="0" id="table211" height="328">
                  <tr>
                    <td height="164" colspan="2" align="middle">
					<form name="form1" method="POST" action="login.php" onSubmit="return Checklogin();">
                        <table cellSpacing="0" cellPadding="0" width="100%" border="0" height="143" id="table212">
                          <tr>
                            <td width="13%" height="38" class="top_hui_text"><span class="login_txt">管理员：&nbsp;&nbsp; </span></td>
                            <td height="38" colspan="2" class="top_hui_text"><input name="username" class="editbox4" value="" size="20">                            </td>
                          </tr>
                          <tr>
                            <td width="13%" height="35" class="top_hui_text"><span class="login_txt"> 密 码： &nbsp;&nbsp; </span></td>
                            <td height="35"  class="top_hui_text"><input class="editbox4" type="password" size="20" name="pwd">
                              <img src="images/luck.gif" width="19" height="18"> </td>
                          </tr>

                          <tr>
                            <td height="35" >&nbsp;</td>
                            <td height="35" colspan="2"><input type="submit" name="submit" class="button" id="Submit" value="登 陆"/>
								<input name="cs" type="reset" class="button" id="cs" value="重 置"/>
							</td>
                          </tr>
                        </table>
                        <br>
                    </form>
					</td>
                  </tr>
                  <tr>
                    <td width="433" height="164" align="right" valign="bottom"><img src="images/login-wel.gif" width="242" height="138"></td>
                    <td width="57" align="right" valign="bottom">&nbsp;</td>
                  </tr>
              </table></td>
            </tr>
          </table>
          </td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="20"><table width="100%" border="0" cellspacing="0" cellpadding="0" class="login-buttom-bg">
      <tr>
        <td align="center"><span class="login-buttom-txt">Copyright &copy; 2010-2012 深圳酒业协会</span></td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>